﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SelectOperDistRoleDeptUnite.aspx.cs" Inherits="CommonPages_SelectOperDistRoleDeptUnite" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>无标题页</title>
    <style type="text/css">
        /*.no-Icon
        {
            display: none;
        }
        .x-check-group-alt
        {
            background: #D1DDEF;
            border-top: 1px dotted #B5B8C8;
            border-bottom: 1px dotted #B5B8C8;
        }*/
    </style>

    <script type="text/javascript" src="../JavaScript/Common.js"></script>
    <link href="../css/PageStyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function nodeLoad(node) {
            Ext.net.DirectMethods.NodeLoad(node.id, node.getUI().isChecked(), {
                success: function(result) {
                    var data = eval("(" + result + ")");
                    node.loadNodes(data);
                },
                failure: function(errorMsg) {
                    Ext.Msg.alert('Failure', errorMsg);
                }
            });
        }
        function ConfirmClose() {
            Ext.net.DirectMethods.GetReturnValues({
                success: function(result) {
                    if (result != "") {
                        parent.GridCellValue(result);
                    }
                    Closepopwin();
                }
            });
        }
        function AddUser() {
            extHid_UserIds.value = getCheckedNode();
            extBtn_AddUsers.fireEvent("click", "");
        }
        function getCheckedNode() {
            var result = "";
            var checkeds = "";
            if (extradi_Operator.checked)
                checkeds = Ext.getCmp('TreePanel1').getChecked();
            else {
                if (extradi_Role.checked)
                    checkeds = Ext.getCmp('TreePanel2').getChecked();
                else {
                    if (extradi_Dept.checked)
                        checkeds = Ext.getCmp('TreePanel3').getChecked();
                }
            }
            for (var i = 0; i < checkeds.length; i++) {
                result = result + checkeds[i].id + ";";
            }
            result = result.substring(0, result.length - 1)
            return result;
        }

        function nodeLoadWin(node) {
            Ext.net.DirectMethods.NodeLoadWin(node.id, {
                success: function(result) {
                    var data = eval("(" + result + ")");
                    node.loadNodes(data);
                },
                failure: function(errorMsg) {
                    Ext.Msg.alert('Failure', errorMsg);
                }
            });
        }

        function deptNodeLoad(node) {
            Ext.net.DirectMethods.DeptNodeLoad(node.id, {
                success: function(result) {
                    var data = eval("(" + result + ")");
                    node.loadNodes(data);
                },
                failure: function(errorMsg) {
                    Ext.Msg.alert('Failure', errorMsg);
                }
            });
        }

        function TypeControl() {
            if (extradi_Operator.checked) {
                extpanl_Operator.show();
                extpanl_Role.hide();
                extpanl_Dept.hide();
                extHidn_Type.value = "0";
            }
            else {
                if (extradi_Role.checked) {
                    extpanl_Operator.hide();
                    extpanl_Role.show();
                    extpanl_Dept.hide();
                    extHidn_Type.value = "1";
                }
                else {
                    if (extradi_Dept.checked) {
                        extpanl_Operator.hide();
                        extpanl_Role.hide();
                        extpanl_Dept.show();
                        extHidn_Type.value = "2";
                    }
                }
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" AjaxViewStateMode="Enabled" />
    <table width="100%" border="0" style="height: 380px;">
        <tr>
            <td style="width: 48%;" valign="top">
                <table width="100%" border="0">
                    <tr>
                        <td>
                            <ext:RadioGroup ID="extrdig_Type" runat="server" ItemCls="x-check-group-alt">
                                <Items>
                                    <ext:Radio ID="extradi_Operator" runat="server" BoxLabel="人员" Checked="true">
                                        <Listeners>
                                            <Check Fn="TypeControl" />
                                        </Listeners>
                                    </ext:Radio>
                                    <ext:Radio ID="extradi_Role" runat="server" BoxLabel="角色">
                                        <Listeners>
                                            <Check Fn="TypeControl" />
                                        </Listeners>
                                    </ext:Radio>
                                    <ext:Radio ID="extradi_Dept" runat="server" BoxLabel="部门">
                                        <Listeners>
                                            <Check Fn="TypeControl" />
                                        </Listeners>
                                    </ext:Radio>
                                </Items>
                            </ext:RadioGroup>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <ext:Panel ID="extpanl_Operator" runat="server" Height="380" Width="250" Border="false" AutoScroll="true"
                                HideMode="Offsets" Layout="Fit">
                                <Content>
                                    <%--<ext:FitLayout ID="FitLayout1" runat="server">--%>
                                        <ext:TreePanel ID="TreePanel1" runat="server" Lines="true" Border="false" 
                                            CollapseFirst="false" AutoScroll="true" ContainerScroll="true">
                                            <Listeners>
                                                <BeforeLoad Fn="nodeLoad" />
                                                <CheckChange Fn="checkNode" />
                                            </Listeners>
                                        </ext:TreePanel>
                                    <%--</ext:FitLayout>--%>
                                </Content>
                            </ext:Panel>
                            <ext:Panel ID="extpanl_Role" runat="server" Border="false" Height="380" Width="250"
                                Hidden="true" HideMode="Offsets" Layout="Fit">
                                <Content>
                                    <%--<ext:FitLayout ID="FitLayout3" runat="server">--%>
                                        <ext:TreePanel ID="TreePanel2" runat="server" Lines="true" Border="false" 
                                            CollapseFirst="false" AutoScroll="true" ContainerScroll="true">
                                            <Listeners>
                                                <BeforeLoad Fn="nodeLoadWin" />
                                            </Listeners>
                                            <LoadMask ShowMask="true" />
                                        </ext:TreePanel>
                                    <%--</ext:FitLayout>--%>
                                </Content>
                            </ext:Panel>
                            <ext:Panel ID="extpanl_Dept" runat="server" Border="false" Height="380" Width="250"
                                Hidden="true" HideMode="Offsets" Layout="Fit">
                                <Content>
                                    <%--<ext:FitLayout ID="FitLayout4" runat="server">--%>
                                        <ext:TreePanel ID="TreePanel3" runat="server" Lines="true" Border="false" 
                                            CollapseFirst="false" AutoScroll="true" ContainerScroll="true">
                                            <Listeners>
                                                <BeforeLoad Fn="deptNodeLoad" />
                                            </Listeners>
                                            <LoadMask ShowMask="true" />
                                        </ext:TreePanel>
                                    <%--</ext:FitLayout>--%>
                                </Content>
                            </ext:Panel>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 10%;" valign="middle">
                <table border="0">
                    <tr>
                        <td>
                            <ext:Button ID="extBtn_Add" runat="server" Text="－＞">
                                <Listeners>
                                    <Click Fn="AddUser" />
                                </Listeners>
                            </ext:Button>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <ext:Button ID="extBtn_Delete" runat="server" Text="删除">
                                <DirectEvents>
                                    <Click OnEvent="DelUser_Click">
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 42%;" valign="top">
                <table width="100%">
                    <tr style="height: 25px;">
                        <td>
                            <label style="font-size: 9pt;">
                                被选对象：</label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <ext:Store ID="Store1" runat="server" AutoLoad="true">
                                <Reader>
                                    <ext:JsonReader IDProperty="NUMBER">
                                        <Fields>
                                            <ext:RecordField Name="TYPE" />
                                            <ext:RecordField Name="NUMBER" />
                                            <ext:RecordField Name="NAME" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                            <ext:Panel ID="Panel2" runat="server" Height="385" Width="220" Border="false" Layout="Fit">
                                <Content>
                                    <%--<ext:FitLayout ID="FitLayout2" runat="server">--%>
                                        <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true"
                                            TrackMouseOver="true">
                                            <ColumnModel ID="ColumnModel1" runat="server">
                                                <Columns>
                                                    <ext:RowNumbererColumn Header="序号" Width="30" />
                                                    <ext:Column Header="类型" DataIndex="TYPE" Width="40">
                                                        <Renderer Handler="if(value=='0')  return '人员';  if(value=='1') return '角色';  if(value=='2')  return '部门';" />
                                                    </ext:Column>
                                                    <ext:Column ColumnID="NUMBER" Header="编号" DataIndex="NUMBER" Width="50">
                                                    </ext:Column>
                                                    <ext:Column Header="名称" DataIndex="NAME" Width="70">
                                                    </ext:Column>
                                                </Columns>
                                            </ColumnModel>
                                            <SelectionModel>
                                                <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" ColumnPosition="1"
                                                    Width="20" AllowDeselect="true">
                                                </ext:CheckboxSelectionModel>
                                            </SelectionModel>
                                            <LoadMask ShowMask="true" />
                                        </ext:GridPanel>
                                    <%--</ext:FitLayout>--%>
                                </Content>
                            </ext:Panel>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="height: 10px;">
            </td>
        </tr>
        <tr>
            <td style="width: 100%;" colspan="3" align="center">
                <table>
                    <tr>
                        <td>
                            <ext:Button ID="btnSave" runat="server" Text="确定" Icon="Disk">
                                <Listeners>
                                    <Click Fn="ConfirmClose" />
                                </Listeners>
                            </ext:Button>
                        </td>
                        <td>
                            <ext:Button ID="btnCancel" runat="server" Text="关闭" Icon="Cancel">
                                <Listeners>
                                    <Click Fn="Closepopwin" />
                                </Listeners>
                            </ext:Button>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <ext:Hidden ID="extHid_UserIds" runat="server" Text="">
    </ext:Hidden>
    <ext:Hidden ID="extHidn_Type" runat="server" Text="0">
    </ext:Hidden>
    <ext:Button ID="extBtn_AddUsers" runat="server" Hidden="true">
        <Listeners>
            <Click Handler="Ext.net.DirectMethods.refrashDataEvent(#{extHid_UserIds}.value,#{extHidn_Type}.value);" />
        </Listeners>
    </ext:Button>
    </form>
</body>
</html>
